if __name__ == '__main__':
    # P51---基础函数
    def add(param1, param2):
        """
        两个参数相加
        :param param1:
        :param param2:
        :return:
        """
        return param1 + param2
    print(add(1, 2))


    # P54---global关键字
    num = 100
    def test_global():
        global num
        num = 500
        return num
    print(test_global())


    # P81---函数多返回值
    def get_num():
        return 111,"xxx",[1,2,3,4,5]
    x,y,z = get_num()
    print(x)
    print(y)
    print(z)


    # P82---函数的多种参数
    # 必备参数
    def test_param1(param1,param2):
        return param1,param2
    print(test_param1("AAA","BBB"))
    # 关键字参数
    def test_param2(param1,param2):
        return param1,param2
    print(test_param2(param2="CCC",param1="DDD"))
    # 默认参数
    def test_param3(param1,param2="YYY"):
        return param1,param2
    print(test_param3("EEE"))
    # 不定长参数
    def test_param4(*arg):
        return arg
    print(test_param4("GGG","HHH","QQQ","WWW","EEE"))
    def test_param5(**arg):
        return arg
    print(test_param5(name="黑大帅",age="18",gender="男"))


    # P84---匿名函数
    test_lambada = lambda param1,param2: param1+param2
    print(test_lambada(100,900))